{% import 'macros/form.html' as form %}
{% extends "package/resource_edit_base.html" %}

{% block subtitle %}{{ _('View') }} {{ g.template_title_delimiter }} {{ h.resource_display_name(res) }}{% endblock %}

{% block page_primary_action %}
  <div class="btn-group">
    <a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
      <i class="fa fa-plus-square"></i>
      {{ _('New view') }}
      <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      {% for option in h.get_allowed_view_types(resource, pkg_dict)  %}
        {% set url = h.url_for(pkg_dict.type ~ '_resource.edit_view', id=pkg_dict.name, resource_id=resource.id, view_type=option[0]) %}
        <li><a href="{{ url }}"><i class="fa fa-{{ option[2] }}"></i> {{ option[1] }}</a></li>
      {% endfor %}
    </ul>
  </div>
  {% asset 'vendor/reorder' %}
{% endblock %}

{% block primary_content_inner %}
  {% if views %}
    {% snippet "package/snippets/resource_views_list.html", views=views, pkg=pkg, is_edit=true, extra_attributes='data-module = resource-view-reorder data-module-id=' + resource.id, extra_class='resource-view-list nav-pills nav-stacked' %}
  {% else %}
    <p class="empty">{{ _('This resource has no views') }}</p>
  {% endif %}
{% endblock %}
